package com.ys.erp.common.util;

import jakarta.validation.constraints.NotNull;
import org.apache.commons.lang3.ObjectUtils;

import java.util.Random;

/**
 * @author lwj
 * @date 2024/10/21
 */
public class YsStringUtil {

    /**
     * 生成6位验证码
     *
     * @return              验证码
     */
    public static int generateRandomSixDigitNumber() {
        Random random = new Random();
        int min = 100000;
        int max = 999999;
        return random.nextInt((max - min) + 1) + min;
    }

    public static boolean isVideo(String link) {
        return link.endsWith("mp4")
                || link.endsWith("avg");
    }

    public static String disposePhone(@NotNull String phone) {
        if (ObjectUtils.isEmpty(phone)) {
            return null;
        }
        if (phone.length() < 11) {
            return null;
        }
        return phone.substring(0, 3)
                + "****"
                + phone.substring(7);
    }

}
